<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <link rel="stylesheet" href="./css/base.css" />
    <link rel="stylesheet" href="./css/wode.css" />
    <link rel="stylesheet" href="./iconfont/iconfont.css" />
  </head>
  <body>
    <header>
      <img src="./imgs/user-header2.png" alt="" />
      <div class="to">
        <div class="sum"><img src="./imgs/default-avatar.png" alt="" /></div>
        <div class="sun">
          <p>未登录</p>
          <span>点击登录账号</span>
        </div>
      </div>
    </header>
    <div class="box">
      <div class="left">
        <div>
          <span>--</span>
          <p>账户余额</p>
        </div>
        <div>
          <span>--</span>
          <p>积分</p>
        </div>
        <div>
          <span>--</span>
          <p>优惠券</p>
        </div>
      </div>
      <div class="folt">
        <i class="iconfont icon-qianbao"></i>
        <p>我的钱包</p>
      </div>
    </div>
    <div class="mask">
      <a href="#">
        <i class="iconfont icon-31dingdan"></i>
        <p>全部订单</p>
      </a>
      <a href="#">
        <i class="iconfont icon-qianbao"></i>
        <p>待支付</p>
      </a>
      <a href="#">
        <i class="iconfont icon-daifahuo"></i>
        <p>待收货</p>
      </a>
      <a href="#">
        <i class="iconfont icon-daishouhuofuwu"></i>
        <p>已收货</p>
      </a>
    </div>
    <div class="nav">
      <div class="lol">我的服务</div>
      <div class="main">
        <a href="#">
          <i class="iconfont icon-weibiaoti2fuzhi08"></i>
          <p>收货地址</p>
        </a>
        <a href="#">
          <i class="iconfont icon-lingquanzhongxin"></i>
          <p>领券中心</p>
        </a>
        <a href="#">
          <i class="iconfont icon-youhuiquan-copy"></i>
          <p>优惠券</p>
        </a>
        <a href="#">
          <i class="iconfont icon-bangzhu"></i>
          <p>帮助</p>
        </a>
        <a href="#">
          <i class="iconfont icon-jifen"></i>
          <p>积分</p>
        </a>
        <a href="#">
          <i class="iconfont icon-shouhou"></i>
          <p>售后</p>
        </a>
      </div>
    </div>
    <div class="zfh">
      <span>
        退出登录
      </span>
    </div>
    <footer>
      <a href="./智慧商城首页.html">
        <i class="iconfont icon-shouye"></i>
        <p>首页</p>
      </a>
      <a href="./智慧商城分类.html">
        <i class="iconfont icon-fenlei"></i>
        <p>分类</p>
      </a>
      <a href="./购物车.html">
        <i class="iconfont icon-gouwuchekong"></i>
        <p>购物车</p>
      </a>
      <a href="./我的.html">
        <i class="iconfont icon-wode"></i>
        <p>我的</p>
      </a>
    </footer>
  </body>
</html>
<script src="./axios.js"></script>
  <script src="./js/commit.js"></script>
<script>
  document.querySelector('.to').addEventListener('click',function () {
    location.href = './登录页面.html'
  })
  const res = async ()=>{
     const a =  await axios.get('/user/info')
     console.log(a)
     const data = a.data.data.userInfo
     document.querySelector('.sun').innerHTML = `
         <p>${data.nick_name}</p>
         <span>${data.mobile}</span>
     `
     document.querySelector('.zfh').style.display = 'block'
     document.querySelector('.zfh').addEventListener('click',function () {
      localStorage.removeItem('token')
      location.href = './登录页面.html'
     })
    }
    res()

    const data = async ()=>{
      const res = await axios.get('/user/assets')
      console.log(res)
      document.querySelector('.left').innerHTML = `
     <div>
          <span>${res.data.data.assets.balance}</span>
          <p>账户余额</p>
        </div>
        <div>
          <span>${res.data.data.assets.points}</span>
          <p>积分</p>
        </div>
        <div>
          <span>${res.data.data.assets.coupon}</span>
          <p>优惠券</p>
     `
    }
    data()
</script>
